package me.shiqiang.im.action;

import com.tst.common.returnobj.BaseReturnObj;
import com.tst.common.returnobj.ReturnObj;
import com.tst.common.returnobj.ReturnObjCode;
import me.shiqiang.im.service.EmojiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created by John on 2018/6/15
 */
@RestController
@RequestMapping("im/emoji")
public class EmojiAction {

    @Autowired
    EmojiService emojiService;


    @PostMapping("/saveOfficial/{seriesName}")
    public void saveOfficial(@RequestParam("file") MultipartFile[] multipartFile, @PathVariable String seriesName) {
        emojiService.saveOffical(multipartFile, seriesName);
    }

    @PostMapping("/save")
    public BaseReturnObj save(@RequestParam("file") MultipartFile multipartFile) {
        return new BaseReturnObj(ReturnObjCode.SUCCESS, emojiService.save(multipartFile));
    }


    @GetMapping("/get")
    public ReturnObj<String> get(Long groupId, Long fileId) {
        String url = emojiService.get(groupId, fileId);
        return new ReturnObj<>(ReturnObjCode.SUCCESS, "", url);
    }

    @GetMapping("/getAllOffical")
    public ReturnObj getAllOffical() {
        return new ReturnObj<>(ReturnObjCode.SUCCESS, "", emojiService.getAllOffical());
    }
}
